<template>
	<DetailPage v-bind="detailConfig" :model="nowData"></DetailPage>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod'
import DetailPage from '@/views/aplid/DetailPage/index.vue'
import { detailConfig } from '../../config'
import { getAreaObj } from '@/utils/util'
import { useCommonStore } from '@/stores/common'

const { setLoading, setDetailHeadData } = useCommonStore()

const nowRowData: any = inject('nowRowData')
const props = defineProps({
	chainViewInfo: {
		type: Object,
		default: () => ({}),
	},
	isBlockchain: {
		type: Boolean,
		default: false,
	},
})

const nowData: any = ref({})
const loading = ref(false)
const getInitData = () => {
	loading.value = true
	setLoading()
	// apiMod.view_dpFoundationPractitioners_staffByIdCard(nowRowData.idCard).then((res) => {
	apiMod.view_dpFoundationPractitioners_view(nowRowData.id).then((res) => {
		const crAreas: any = getAreaObj(res.data, 'cr', 'get')
		const areas: any = getAreaObj(res.data, '', 'get')
		const unitAddress: any = getAreaObj(res.data, 'unit', 'set')

		nowData.value = {
			...res.data,
			crAreasName: crAreas.names,
			areasName: areas.names,
			unitAddress: unitAddress.names,
		}
		setLoading()
		setDetailHeadData({ ...nowData.value })
		loading.value = false
	})
}

onMounted(() => {
	if (props.isBlockchain) {
		nowData.value = props.chainViewInfo
	} else {
		getInitData()
	}
})
</script>

<style scoped>
.detail-label {
	color: #eee;
}

.image {
	width: 90%;
	height: 220px;
	display: block;
}
</style>
